package io;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author Cheng Jun
 * Description: BufferedWriter 缓存的字符输出流
 * 不要处理二进制文件(声音，视频，图片，pdf等)
 * @version 1.0
 * @date 2022/8/14 12:55
 */
public class BufferedWriterExample {

    public static void main(String[] args) throws IOException {
        write("追加模式写入数据");
    }

    private static void write(String str) throws IOException {
        // 追加模式 写入数据
        FileWriter fileWriter = new FileWriter("src/io/TestFile/ForChar.txt", true);
        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
        // 换行
        bufferedWriter.newLine();
        bufferedWriter.write(str);
        bufferedWriter.newLine();
        bufferedWriter.write(str);
        bufferedWriter.close();
    }

}
